/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.dao.impl;

import com.ivanbiz.dao.MemberCustomerDAO;
import com.ivanbiz.helper.HibernateUtil;
import com.ivanbiz.model.MemberCustomer;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Administrator
 */
public class MemberCustomerDAOImpl extends GenericDAOImpl implements MemberCustomerDAO {

    @Override
    public MemberCustomer getCustomer(String noTransaksi) throws Exception {
        try {
            Session session = HibernateUtil.getSession();
            String sql = "select distinct(me) from Piutang pi,Penjualan pe,MemberCustomer me "
                    + "where pi.noTransaksi = pe.noTransaksi and pi.noTransaksi = '" + noTransaksi + "'";
            MemberCustomer memberCustomer = (MemberCustomer) session.createQuery(sql).uniqueResult();
            return memberCustomer;
        } catch (Exception e) {
            HibernateUtil.rollbackTransaction();
            throw e;
        } finally {
            HibernateUtil.closeSession();
        }
    }
}
